// 购物车模块
import request from '../utils/request'
// 加入购物车的接口
export const addCarApi = function (data) {
  return request("/cart/add", data, "post")
}
// 获取购物车数量接口
export const getCartNumApi = function () {
  return request("/Home/Cart/cartnum", { uid: "956519" }, "post")
}
// 获取购物车列表接口 
export const getCartListApi = function () {
  return request("/Cart/lists", { user_id: "956519" }, "post")
}
// 删除购物车接口
/**
 * user_id: 956519
    shop_id: 328
    goods_id: 7257
    sku_id: 0
    pmid: 0
 */
export const delCartApi = function (shop_id, goods_id) {
  return request("/cart/del", {
    user_id: "956519",
    shop_id: shop_id,
    goods_id: goods_id,
    sku_id: "0",
    pmid: 0
  }, "post")
}
// 单个选中接口
export const checkOneApi = function (shop_id, goods_id, is_checked, skuid) {
  console.log(shop_id, goods_id, is_checked)
  return request("/cart/is_checked", {
    user_id: "956519",
    shop_id: shop_id,
    goods_id: goods_id,
    sku_id: skuid,
    is_checked: is_checked,
    pmid: 0
  }, "post")
}
// 店铺全选接口
export const checkShopAllApi = function (shop_id, check) {
  return request("/cart/is_checked", {
    user_id: "956519",
    is_checked: check,
    shop_all: 1, //shopall 店铺全选
    shop_id: shop_id
  }, "post")
}
// 购物车全选
export const cartAllApi = function (check) {
  return request("/cart/is_checked", {
    user_id: "956519",
    check_all: 1, //购物车全选
    is_checked: check
  }, "post")
}
// 购物车数量更新接口
export const updateNumApi = function (shop_id, goods_id, sku_id, num) {
  return request("/Cart/update", {
    user_id: "956519",
    shop_id: shop_id,
    goods_id: goods_id,
    sku_id: sku_id,
    goods_num: num
  }, "post")
}